/**
 *  This file is part of AugeasWH.
 *
 *  AugeasWH. is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  AugeasWH. is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with AugeasWH.  If not, see <http://www.gnu.org/licenses/>.
 */

package cz.fit.vutbr.pis2012.augeaswh.control.whman.stock_items;

import java.io.Serializable;

import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;

import org.richfaces.component.SortOrder;

@ManagedBean
@SessionScoped
public class StockItemsSortingBean implements Serializable {

	private static final long serialVersionUID = 5968840661585485841L;
	
	private SortOrder supplierOrder = SortOrder.unsorted;
	private SortOrder deliveryDateOrder = SortOrder.unsorted;
	private SortOrder StockTypeOrder = SortOrder.unsorted;
	
	public void sortBySupplier() {
		deliveryDateOrder = SortOrder.unsorted;
		StockTypeOrder = SortOrder.unsorted;
        if (supplierOrder.equals(SortOrder.ascending)) {
        	setSupplierOrder(SortOrder.descending);
        } else {
        	setSupplierOrder(SortOrder.ascending);
        }
	}
	
	public void sortByDeliveryDate() {
		supplierOrder = SortOrder.unsorted;
		StockTypeOrder = SortOrder.unsorted;
        if (deliveryDateOrder.equals(SortOrder.ascending)) {
        	setDeliveryDateOrder(SortOrder.descending);
        } else {
        	setDeliveryDateOrder(SortOrder.ascending);
        }
	}
	
	public void sortByStockType() {
		supplierOrder = SortOrder.unsorted;
		deliveryDateOrder = SortOrder.unsorted;
        if (StockTypeOrder.equals(SortOrder.ascending)) {
        	setStockTypeOrder(SortOrder.descending);
        } else {
        	setStockTypeOrder(SortOrder.ascending);
        }
	}
	
	public void setSupplierOrder(SortOrder order) {
		supplierOrder = order;
	}
	
	public SortOrder getSupplierOrder() {
		return supplierOrder;
	}

	public SortOrder getDeliveryDateOrder() {
		return deliveryDateOrder;
	}

	public void setDeliveryDateOrder(SortOrder deliveryDateOrder) {
		this.deliveryDateOrder = deliveryDateOrder;
	}

	public SortOrder getStockTypeOrder() {
		return StockTypeOrder;
	}

	public void setStockTypeOrder(SortOrder stockTypeOrder) {
		StockTypeOrder = stockTypeOrder;
	}

	
	
}
